﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cinemax.DAO;

namespace Cinemax.UserControl
{
    public partial class wuc_Login : System.Web.UI.UserControl
    {
        public string username = "";
        public bool islogin = false;
        public int point = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["user_login"] != null)
            {
                string user_login = Session["user_login"].ToString();
                int id = int.Parse(user_login);
                username = TaiKhoanDAO.GetUsernameByID(id);
                point = TaiKhoanDAO.GetPointByID(id);
                if (username == String.Empty)
                {
                    username = "Khách";
                    islogin = false;
                }
                else
                {
                    islogin = true;
                }
            }
        }

        protected void Login_Click(object sender, EventArgs e)
        {
            string user = txtuid.Text.Trim();
            string pass = txtpass.Text.Trim();
            int a = TaiKhoanDAO.CheckLogin(user, pass);
            if (a != -1)
            {
                Session["user_login"] = a;
                Response.Redirect("personalize.aspx");
            }
            else
            {
            }
        }
    }
}